package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.OrderAddress;
import com.xinhe.web.request.OrderAddressModel;
import com.xinhe.web.request.ServiceCenterQuery;
import com.xinhe.web.service.AliyunService;
import com.xinhe.web.service.OrderAddressService;
import com.xinhe.web.service.ServiceCenterService;
import com.xinhe.web.util.ValidatorUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

@Api(value = "订单地址", tags = {"订单地址"})
@RestController
@RequestMapping(value = {"/orderAddress"}, produces = {"application/json;charset=UTF-8"})

public class OrderAddressController {
    @Autowired
    private OrderAddressService orderAddressService;

    @ApiOperation(httpMethod = "GET", value = "分页查询订单地址")
    @RequestMapping({"/pageOrderAddress"})
    public QueryResults<OrderAddress> pageOrderAddress(int pageNum, int pageSize) {
        return this.orderAddressService.pageOrderAddress(pageNum, pageSize);
    }

    @ApiOperation(httpMethod = "POST", value = "保存订单地址")
    @RequestMapping({"/saveOrderAddress"})
    public Result saveOrderAddress(@Valid OrderAddressModel model) {
        return this.orderAddressService.saveModel(model);
    }

    @ApiOperation(httpMethod = "GET", value = "删除订单地址")
    @ApiImplicitParam(name = "orderAddressId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteOrderAddress"})
    public Result deleteOrderAddress(Long orderAddressId) {
        return this.orderAddressService.delete(orderAddressId);
    }
    @ApiOperation(httpMethod = "GET", value = "订单地址详情")
    @ApiImplicitParam(name = "orderAddressId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailOrderAddress"})
    public Result detailOrderAddress(Long orderAddressId) {
        return this.orderAddressService.findById(orderAddressId);
    }
}
